package cn.hdu.liang.nio;

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Disk {
    public static void main(String[] args) throws IOException {
        //FileSystem fs = FileSystems.getDefault();
        //fs.getFileStores().forEach(System.out::println);

        print(Files.getFileStore(Paths.get("/home/liang")));
    }

    public static void print(FileStore store) throws IOException {
        long total = store.getTotalSpace();
        long used = store.getTotalSpace() - store.getUnallocatedSpace();
        long usable = store.getUsableSpace();
        System.out.println(store.toString());
        System.out.println("总容量：" + total);
        System.out.println("已用空间：" + used);
        System.out.println("可用空间：" + usable);
    }
}
